package huanzhao.erp.domain.types;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author April
 * 2024/6/13 上午11:41
 * @version 1.0
 */
@Getter
public enum TaskState {
    WAIT_RECEIVE("待接收"),
    PROCESSING("处理中"),
    TRANSFERRING("移交中"),
    EXCEPTION("异常"),
    FINISHED("完成"),
    REASSIGNED("已转调");

    @EnumValue
    @JsonValue
    private final String value;

    TaskState(String value) {
        this.value = value;
    }

    public static TaskState of(int taskTypeCode) {
        return switch (taskTypeCode) {
            case 0 -> WAIT_RECEIVE;
            case 1 -> PROCESSING;
            case 2 -> TRANSFERRING;
            case 3 -> EXCEPTION;
            case 4 -> FINISHED;
            default -> REASSIGNED;
        };
    }
}
